<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('api56', 'iappVideo', 0);
pc_base::load_app_class('admin','admin',0);
pc_base::load_sys_class('form', '', 0);
class callback extends admin {
	function __construct() {
		$this->iappVideo = pc_base::load_model('iappVideo_model');
 	}
	
	//http://www.zuiqianduan.cn/index.php?m=iappVideo&c=callback&a=success&vid=105880019&url=http%3A%2F%2Fwww.56.com%2Fu14%2Fv_MTA1ODgwMDE5.html&sid=1&category=DGoVu7&msg=%25E4%25B8%258A%25E4%25BC%25A0%25E6%2588%2590%25E5%258A%259F&subject=big_buck_bunny&result=1&player=http%3A%2F%2Fplayer.56.com%2F3000001713%2Fopen_MTA1ODgwMDE5.swf&cover=http%3A%2F%2Fimg.v3.pfs.56img.com%2Fimages%2F13%2F26%2Fcoop_3000001713i56olo56i56.com_cw_139159077528hd.jpg&chk=n&coop_public=y&forbid=n&coopid=coop_3000001713&attach=ok&tags=big_buck_bunny,&content=big_buck_bunny
	/*
	* 上传成功时回调
	*/
	public function success() {
		$result = $_GET['result'];
		if($result){
			$vid = intval($_GET['vid']);
			$_data = Open::Video_GetVideoInfo(array('vid'=>$vid));
			if($_data[code]==0){
				$_data = $_data[0];
				
				$data[userid] = $_SESSION['userid'];;
				$data[username] = param::get_cookie('admin_username');
				
				$data['vid'] = $_data['vid'];
				$data['title'] = trim($_data['title']);
				$data['content'] = trim($_data['desc']);
				$data['tags'] = trim($_data['tags']);
				$data['thumb'] = $_data['bimg'];
				$data['player'] = $_data[swf];
				$data['url_56'] = $_data[url];
				$data['video_url'] = "http://vxml.56.com/html5/".$_data['vid']."/?src=m&res=vga";
				$data['totaltime'] = $_data[totaltime];
				
				$data['forbid'] = 'n';
				$data['chk'] = 'y';
				$data['vtypes'] = 1;
				$data['addtime'] = time();
				$data['edittime'] = time();

				$videoid = $this->iappVideo->insert($data,true);
				
				echo '<script language="javascript" type="text/javascript">
							window.top.art.dialog(
							{
								id:"set_content",
								content:"视频上传成功",
								title:"提示",
								button: [
									{
										name: "确定",
										callback: function () {
											var url = window.top.document.getElementById("rightMain").src;
											top.document.getElementById("rightMain").src=url; 
										}
									}
								]
							});	
					</script>';
					
					
				
			}else{
				echo '<script language="javascript" type="text/javascript">
							window.top.art.dialog(
							{
								id:"set_content",
								content:"视频上传成功，本地入库失败，请手动导入",
								title:"提示",
								button: [
									{
										name: "确定",
										callback: function () {
											var url = window.top.document.getElementById("rightMain").src;
											top.document.getElementById("rightMain").src=url; 
										}
									}
								]
							});	
					</script>';
			}
		
		}
	}
	
	/*
	* 上传失败时回调
	*/
	public function failure() {
		$msg = urldecode($_GET["msg"]);
		echo '<script language="javascript" type="text/javascript">
					alert("'.$msg.'");
					parent.window.location.href="index.php?m=iappVideo&c=manages&a=init&menuid='.$_GET['menuid'].'&pc_hash='.$pc_hash.'";
			</script>';
	}
}
?>